/**
 * @author Rudy Kaplan Depena (The University of Texas at Austin)
 */
package com.utaustin.mirankerlab.ultrawrap.compiler.components;

import java.util.Map;
import java.util.HashMap;
import java.util.Set;

/** A Library of Prefix Pairs */
public class PrefixMap {

	//instance variables
	private Map<String, String> prefixes;
	
	/**
	 * Default Constructor
	 */
	public PrefixMap(){
		prefixes = new HashMap<String, String>();
	}
	
	/**
	 * Add prefix pair (i.e. (tag, iri))
	 * @param tag
	 * @param iri
	 */
	public void addPrefix(String tag, String iri){
		prefixes.put(tag, iri);
	}
	
	/**
	 * Given a tag, get associated iri
	 * @param tag
	 * @return iri
	 */
	public String getIRI(String tag){
		String rawIri = prefixes.get(tag);
		return rawIri.substring(1, rawIri.length()-1);
	}
	
	/**
	 * Acquire set of Tags to traverse through all IRI's
	 * @return Set of Tags
	 */
	public Set<String> getTags(){
		return prefixes.keySet();
	}
	
	/**
	 * If tag exists, then true, else false
	 * @param tag
	 * @return
	 */
	public boolean doesTagExist(String tag){
		return prefixes.containsKey(tag);
	}
	
}
